import { observable, action, runInAction } from "mobx";
import * as 登录api from "@/service/api/AdminApi";
import { base64_to_str } from "../../utils/utils";
import { str_to_base64 } from "../../utils/utils";
class AdminStore {
  @observable showClause = false; //是否展示服务条款
  @observable activeKey = "1"; //当前激活的是哪个tab
  @observable toast_display = false;
  @observable suqare_display = false;
  @observable token = undefined; //登录token判断是否可以登录
  @observable userName = "";//这个实际上不是用户名，目前是每个人的仓库名，就是deafult
  @observable UserId = '';
  @observable test = true;

  @action test = () => {
    console.log(this.test);
  }
  @action change_token = token => {
    this.token = token;
  };
  @action a_suqare_display = display => {
    if (display) {
      this.suqare_display = true;
    } else {
      this.suqare_display = false;
    }
  };
  @action a_show_toast_display = () => {
    this.toast_display = true;
  };
  @action a_show_toast_displayFalse = () => {
    this.toast_display = false;
  };
  @action a_showClause = () => {
    this.showClause = true;
  };
  @action a_showClauseFalse = () => {
    this.showClause = false;
  };
  @action a_activeKey = which => {
    this.activeKey = which;
  };
  @action token_get_user_name = async token => {
    await 登录api.token_get_user_name(token).then(res => {
      console.log(res);
      runInAction(() => {
        if (res.code === 200) {
          // this.userName = res.data.user;
          this.userName = "default";
          this.UserId = res.data.user
        }
      });
    });
  };
}

export default new AdminStore();
